package com.cq.androidtools.jetpack.navigation.user

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.cq.androidtools.R
import com.google.android.material.bottomnavigation.BottomNavigationView

/**
 * 作者: CQ
 * 日期: 2021-06-02
 * 说明:
 */
class NavigationMainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_naivgation1)


        //fragment的容器视图，navHost的默认实现——NavHostFragment
        val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragment) as NavHostFragment

        //管理应用导航的对象
        val navController = navHostFragment.navController

        //fragment与BottomNavigationView的交互交给NavigationUI
        findViewById<BottomNavigationView>(R.id.bottom_nav_view).setupWithNavController(navController)
    }

}